package com.resurvolution.kingcloudmusicspringboot.common.utils;

import com.resurvolution.kingcloudmusicspringboot.common.constant.ResultConstant;
import lombok.Data;

@Data
public class UnifyResult<T> {
    private int code;
    private String msg;
    private T data;

    public static <T> UnifyResult<T> success(T data) {
        UnifyResult<T> result = new UnifyResult<T>();
        result.code = ResultConstant.SUCCESS;
        result.msg = "请求成功";
        result.data = data;
        return result;
    }

    public static <T> UnifyResult<T> error(int code, String msg) {
        UnifyResult<T> result = new UnifyResult<T>();
        result.code = code;
        result.msg = msg;
        return result;
    }
}
